home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_075 / dum2 / src / dudir.def next >
Text File  |  1992-05-06  |  2KB  |  78 lines

  1. DEFINITION MODULE DuDir;
  2.  
  3. (* MODULE to read the directory of a current device or directory and
  4.    place names/sizes into DirTable  - also to Sort them in alphabetical
  5.    order (case insensitive)
  6. *)
  7.  
  8. FROM DOSFiles           IMPORT  FileLock;
  9. FROM Intuition          IMPORT  IntuitionText;
  10.  
  11.  
  12. CONST
  13.   MaxMax                = 300;  (* Changing this allows more/less files  *)
  14.                                 (* eats mucho runtime memory 37 bytes ea *)
  15.                                 (* 300 is enough even for my M2: dir *)
  16. TYPE
  17.   DirInfo       = RECORD
  18.                     FileName    : ARRAY[0..30] OF CHAR;
  19.                     IsDir       : BOOLEAN;
  20.                     IsSelected  : BOOLEAN;
  21.                     WasSelected : BOOLEAN;
  22.                     FileSize    : LONGCARD;
  23.                   END;
  24.  
  25.   DirPtr        = POINTER TO DirInfo;
  26.  
  27. VAR
  28.   DirEntries    : CARDINAL;
  29.   FileText      : IntuitionText;
  30.  
  31.     (* This table is full of pointers to allocated memory for storing
  32.        directory entries   *)
  33.  
  34.   DirTable      : ARRAY[0..MaxMax] OF DirPtr;
  35.   MaxFiles      : CARDINAL;
  36.  
  37. (*--------------------*)
  38.  
  39.  
  40. PROCEDURE ReadDirectory(lock:FileLock):BOOLEAN;
  41. (* Returns true if good read
  42.  
  43.    DirTable[0] contains the directory record and name.
  44.    DirTable[1] - DirTable[DirEntries] contains filenames & other info *)
  45.  
  46.  
  47. (*------------*)
  48.  
  49.  
  50. PROCEDURE QSort;
  51. (* Sort the directory - DirEntries is top 1 is bottom   *)
  52. (* Setup is bubble sort now - will change later         *)
  53. (* Still - only 4 seconds for 230 files at that         *)
  54.  
  55. (*----------*)
  56. PROCEDURE MoveString(VAR tgt,src:ARRAY OF CHAR; po,le:CARDINAL);
  57. (* move max of 'le' chars of src to tgt[po] *)
  58. (* not including ending null                *)
  59.  
  60.  
  61. PROCEDURE DisplayName(file,pos:CARDINAL);
  62.  
  63.  
  64. PROCEDURE DisplayFiles(ind:CARDINAL);
  65.  
  66.  
  67. PROCEDURE NewDir;
  68. (* Display a new directory *)
  69.  
  70.  
  71. PROCEDURE ClearTable;
  72. (* MUST call on exit from program to free DirTable memory used *)
  73.  
  74. END DuDir.
  75.  
  76.  
  77.  
  78.